It can be considered that there are a great variety of terminal products (such as mobile phones) in the current market, and the differences and segmentation of their functions, performance and so on are greater and greater, in addition to the differences of overall dimensions, manufacturers, chips, operating systems, and wireless transmission standards. With the development and expansion of the domestic 3G network and the popularity of mobile phones, the differences between various mobile phones are further expanded. At the same time, it is required by operators that the mobile phones as much as possible have more common functions besides calls, short messages and so on, so as to promote more new businesses in a better way. In this case, the function of supporting JAVA virtual machines is quite important, and it becomes the mandatory requirement of many main operators that the mobile phones are based on the JAVA virtual machines with embedded platforms.
The main function of JAVA virtual machines is to provide a Java 2 Micro Edition (J2ME) application environment for the mobile phones, and the mobile phone users can download, install, run and manage the J2ME application programs by means of wireless network, and so on. At the same time, the preset JAVA applications required by the operators can be preset on the mobile phones. The same JAVA application programs can be used on various mobile phones with the support by the JAVA virtual machines, and thereby the differences between mobile phones are reduced. If the mobile phones have JAVA virtual machines, the operators can develop new businesses easily and flexibly in the conditions that customers do not change their mobile phones, just because the JAVA applications have incomparable cross-platform property. Therefore, besides the basic functions coming along with the mobile phones such as calls, short messages, multimedia messages, visual calls and streaming media players and so on, it is possible to download and install JAVA application programs via JAVA virtual machines to expand the functions of the mobile phones, for example, on-line games, mobile banking services, mobile-phone securities, navigation tools, on-line music, and so on, and thereby the capabilities of mobile phones are greatly improved.
As an application component on a mobile phone, it is inevitable for the JAVA virtual machine to run concurrently with other mobile phone applications (such as calls) and therefore the problems of foreground and background switch will be encountered, no matter whether the operating system in the mobile phone is a single-tasking operating system or a multi-tasking operating system, and whether the JAVA virtual machine is a single-tasking virtual machine or a multi-tasking virtual machine. For example, when a mobile phone user is playing a JAVA game or using a JAVA mobile-phone security service, and if there is an incoming call or an incoming visual call at this time, the JAVA application program is required to be switched to the background and the incoming call is required to be switched to the foreground because the priority of the call is very high; and after the call is over, the JAVA application program is also required to be switched to the foreground so as to run continuously. There are two traditional methods, but both of them have shortcomings: (1) all components of the JAVA virtual machine are suspended and the running JAVA application stops running when the JAVA virtual machine switches to the background; (2) the JAVA virtual machine does not carry out processing when the JAVA virtual machine switches to the background, and the JAVA application runs continuously.
However, there are shortcomings below with respect to the above two methods.
It is fatal for an online real-time application to use the method (1), which may influence user experience severely. As shown in FIG. 1, if a user is playing a JAVA game of multiplayer networking, and the game is interrupted abnormally and cannot continues after the user has received a call; and even worse, when a user is using a mobile-phone security service or mobile banking service, all operations are interrupted after the user has received a call, and all operations need to be carried out again even if no error occurs to cause damages, and thereby the user experience is influenced severely.
It is fatal for a local application with a large number of resources required to use the method (2), which may result in that the local applications cannot be used normally under severe conditions. As shown in FIG. 2, if a JAVA application with a large number of resources required is running, for example, a complex game or a JAVA performance testing software, the CUP occupancy rate may reaches up to 90%. At this time, a visual call is incoming, the JAVA application still runs after the JAVA virtual machine switches to the background, and the CPU occupancy rate is not reduced effectively; and because the visual call requires a large number of resources (such as CPU), the effect of the visual call tends to become poor because the visual call does not obtain enough resources, and even the visual call is failed to be received under severe conditions.
Therefore, a more flexible and effective method must be used to handle with the condition that the JAVA virtual machine runs in the background.